using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class JobSeekers_skills : System.Web.UI.Page
{
    string connectionString = "";
                     
    protected void Page_Load(object sender, EventArgs e)
    {
        connectionString =
        WebConfigurationManager.ConnectionStrings[
        "RecruitVietnam"].ConnectionString;
        if (Session.Contents["jsuserid"] == null)
        {
            Response.Redirect("login.aspx");
        }
        else
            if(!IsPostBack)
                EditSkill();
    }
    void EditSkill()
    {
        SqlServerProvider cls = new 
        SqlServerProvider(connectionString);
        
        cls.CommandText = 
        "select * from tblJSSkills" +
        " where UserID=@UserID";
        cls.ParameterCollection = 
        new string[1]{"@UserID"};
        cls.ValueCollection = new 
        string[1]{Session["jsuserid"].ToString()};
        DataRow dataRow = cls.GetDataRow();
        if (dataRow != null)
        {
            SkillID.Value = dataRow[0].ToString();
            txtSpeed.Text =dataRow[2].ToString();
            txtSoftware.Text = 
            dataRow[3].ToString();
            rblVNSpeaking.SelectedValue 
            = dataRow[4].ToString();
            rblVNReading.SelectedValue 
            = dataRow[5].ToString();
            rblVNListening.SelectedValue 
            = dataRow[6].ToString();
            rblENSpeaking.SelectedValue 
            = dataRow[7].ToString();
            rblENReading.SelectedValue 
            = dataRow[8].ToString();
            rblENListening.SelectedValue 
            = dataRow[9].ToString();
            txtDescription.Text 
            = dataRow[10].ToString();
            btnSave.Text = "Update";
        }                   
       
    }
    protected void btnNext_Click(object sender, EventArgs e)
    {
        if (SkillID.Value != "")
            Response.Redirect("resumes.aspx");
        else
            Response.Redirect("resume.aspx");
        
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        RecruitVietnam cls = new RecruitVietnam();
        cls.ConnectionString = connectionString;
        if (!cls.AddNewOrUpdateSkill(
        ((SkillID.Value!="")?SkillID.Value:"0"), 
        Convert.ToString( 
        Session.Contents["jsuserid"]),
        txtSpeed.Text,
        txtSoftware.Text,
        rblVNSpeaking.SelectedValue,
        rblVNReading.SelectedValue,
        rblVNListening.SelectedValue,
        rblENSpeaking.SelectedValue,
        rblENReading.SelectedValue,
        rblENListening.SelectedValue,
        txtDescription.Text))
            literalError.Text = 
            "Error: " + cls.ErrorMessage;
        else
            if (SkillID.Value != "")
                Response.Redirect("resumes.aspx");
            else
                Response.Redirect("resume.aspx");
    }
}
